package top.lcm889.juc.threadpool;

import java.util.concurrent.*;

/**
 * @author Coder-lcm
 * @date 2021/4/11
 */
public class TestExecutorService {
    public static void main(String[] args) {
        // 创建一个包含6个线程的线程池
        ExecutorService pool = Executors.newFixedThreadPool(6);
        TimeUnit unit;
        BlockingQueue workQueue;
        BlockingQueue blockingQueue = new LinkedBlockingQueue<>();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(4, 10, 3, TimeUnit.SECONDS, blockingQueue);
        for (int i = 0; i < 10; i++) {
            threadPoolExecutor.submit(new Runnable() {  //可以改写成三大函数的写法
                @Override
                public void run() {
                    for (int i1 = 0; i1 < 100; i1++) {
                        System.out.println(Thread.currentThread().getName() + " :" + i1);
                    }
                }
            });
        }
        pool.shutdownNow();
        System.out.println(pool.isShutdown());
        System.out.println(pool.isTerminated());
    }
}
